#ifndef OPTIONSWIDGET_H
#define OPTIONSWIDGET_H

#include <QWidget>
#include <QtGui>
#include "slepbase.h"
#include "filetable.h"


typedef enum{
    Method_Least_R,
    Method_nnLeast_R,
    Method_Logistic_R,
    Method_nnLogistic_R,

    Method_Least_C,
    Method_nnLeast_C,
    Method_Logistic_C,
    Method_nnLogistic_C,

    Method_glLeast_R,
    Method_glLogistic_R,
    Method_mcLeast_R,
    Method_mcLogistic_R,
    Method_mtLeast_R,
    Method_mtLogistic_R,

    Method_mcLeast_C,
    Method_mcLogistic_C,
    Method_mtLeast_C,
    Method_mtLogistic_C,
    Method_fusedLasso

}SLEP_METHOD;

class OptionsWidget : public QDialog{

    Q_OBJECT

public:
	OptionsWidget(SLEP_METHOD method);

	// Create all the tabs using the following functions
    void createTerminationOptions();
    void createStartOptions();
    void createNormalizationOptions();
    void createReguarizationParameterOptions();
    void createMethodFlags();
    void createInputTab();

	// Link the various signals and slots
    void createActions();
	void createButtons();

	// Getting the input
	slep_matrix* getInputA();
	slep_vector* getInputy();

	double getL1RegCoefficient();
	OPTS* getOPTS();

public slots:
    void prepareData();
    void dontRun();

    void setOPTS_tFlag(int tFlag);
    void setOPTS_rFlag(int rFlag);
    void setOPTS_nFlag(int nFlag);
    void setOPTS_maxIter(int maxIter);
    void setOPTS_tol(double tol);
    void setOPTS_init(int init);

    void setOPTS_lFlag(int lFlag);
    void setOPTS_mFlag(int mFlag);
    void setOPTS_rsL2(double rsL2);
	void setOPTS_sWeight1(double sWeight1);
	void setOPTS_sWeight2(double sWeight2);
	void setOPTS_c0(double c0);

	void setOPTS_c0_v(void *c0_v);
	void setOPTS_x0(void *x0);
	void setOPTS_X0(void *X0);

private:
    QLabel *labelInit;
    QButtonGroup *buttonGroupInit;
    QLabel *labelMaxIter;
    QSpinBox *spinBoxMaxIter;
    QLabel *labelTolerance;
    QDoubleSpinBox *dspinBoxTolerance;
    QLabel *labelTFlag;
    QButtonGroup *buttonGroupTFlag;
    QButtonGroup *buttonGroupNorm;
    QLabel *labelNorm;
    QLabel *labelRFlag;

    QButtonGroup *buttonGroupRFlag;

    QButtonGroup *buttonGroupLFlag;
    QButtonGroup *buttonGroupMFlag;
    QLabel *labelLFlag;
    QLabel *labelMFlag;

    QGroupBox *terminationOptions;
    QGroupBox *startOptions;
    QGroupBox *groupBoxWidget;
    QGroupBox *normOptions;
    QGroupBox *regularizationOptions;
    QGroupBox *methodFlags;


    QGroupBox *x0NormOption;
    QGroupBox *c0NormOption;
	FileTable *tablex0;
	FileTable *tablec0;

    QGroupBox *muNormOption;
    QGroupBox *nuNormOption;
    QCheckBox *checkBoxMu;
    QCheckBox *checkBoxNu;

    QPushButton *buttonOk;
    QPushButton *buttonCancel;

    QTabWidget *tabWidget;

    QDoubleSpinBox *spinBoxRsL2;
    QDoubleSpinBox *spinBoxRsL1;

	QCheckBox *checkBoxRandomData;
	QSpinBox *dimension1, *dimension2;
    FileTable *tableFeatureMatrix;
    FileTable *tableLabelVector;
	FileTable *tableGroupIndices;

	slep_matrix *A;
	slep_vector *y;
    OPTS *opts;
	SLEP_METHOD method;

	// For Logistic R
	QDoubleSpinBox *spinBoxsWeight1, *spinBoxsWeight2;

	SLEPItem *itemC0Vector;
	SLEPItem *itemX0;
	SLEPItem *itemx0;

};

#endif // OPTIONSWIDGET_H
